<?php
// 本类由系统自动生成，仅供测试用途
namespace Home\Controller;
use Think\Upload;
// use Think\Controller;
class PublicController extends BaseController {
	
	//生成验证码
    public function verify(){
    	$Verify = new \Think\Verify();
    	$Verify->entry();
    }
    //检测验证码
    public function check_verify($code, $id = ''){
    	$verify = new \Think\Verify();
   	    return $verify->check($code, $id);
    }
    //共用修改单字段的值
    public function gedit(){
    	if(I('id')){
    		 $mod = D(I('table'));
    		 $mod->create();
    		 $mod->save();
    		$this->ajaxReturn('修改成功！');
    	}
    	$this->ajaxReturn('修改失败！');
    }
    public function uploadpic(){
    	$this->ajaxReturn(implode('|_|', $this->editpic()));
    }
    //图片上传类
    public function editpic() {
    	$upload = new Upload(); // 实例化上传类
    
    	$upload->maxSize = 2097152; // 设置附件上传大小
    
    	$upload->exts = array('jpg', 'gif', 'png', 'jpeg'); // 设置附件上传类型
    
    	$upload->savePath = "./pic"; // 设置附件上传目录
    
    	$upload->autoSub = true;
    
    	$info = $upload->upload();
    	if (!$info) {// 上传错误提示错误信息
//     		$this->ajaxReturn($upload->getError());
echo 1;
    	} else {// 上传成功 获取上传文件信息
//     		$this->ajaxReturn($info);
echo 2;
    	}
    }
}